package org.jinyan.constant;

import org.jinyan.utils.CommonUtils;

/**
 * 系统服务端URL管理类，使用单例管理所有URL
 * 
 * @author JinYan
 * @version 1.0
 */
public class RemoteServiceSiteURL {

	private String serviceSiteRoot;
	private static RemoteServiceSiteURL instance;

	private RemoteServiceSiteURL() {
		try {
			String path = CommonUtils.getPackagePath("/etc/servicesite.xml");
			String siteRoot = (String) CommonUtils.readFromProperties(path,
					"SERVICE_SITE_ROOT");
			if (siteRoot != null) {
				this.setServiceSiteRoot(siteRoot);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public static synchronized RemoteServiceSiteURL getInstance() {
		if (instance == null) {
			instance = new RemoteServiceSiteURL();
		}
		return instance;
	}

	/**
	 * 获取服务器端的根站点
	 * 
	 * @return
	 */
	public String getServiceSiteRoot() {
		return serviceSiteRoot;
	}

	/**
	 * 设置服务器端的根站点
	 * 
	 * @param serviceSiteRoot
	 */
	public void setServiceSiteRoot(String serviceSiteRoot) {
		this.serviceSiteRoot = serviceSiteRoot;
	}

	/**
	 * 获取服务端的登陆URL
	 * 
	 * @return
	 */
	public String getLoginUrl() {
		return serviceSiteRoot + "/resource/auth/login";
	}

	/**
	 * 获取服务端重新登陆的URL
	 * 
	 * @return
	 */
	public String getReLoginUrl() {
		return serviceSiteRoot + "/resource/auth/reLogin";
	}

	/**
	 * 获取服务端退出的URL
	 * 
	 * @return 服务端退出的URL
	 */
	public String getLogoutUrl() {
		return serviceSiteRoot + "/resource/auth/logout";
	}

	/**
	 * 获取服务端解锁验证的URL
	 * 
	 * @return 服务端解锁验证的URL
	 */
	public String getCheckCredentialsUrl() {
		return serviceSiteRoot + "/resource/auth/checkCredentials";
	}

	/**
	 * 获取所有任务调度的URL
	 * 
	 * @return
	 */
	public String getMyTasksUrl() {
		return serviceSiteRoot + "/resource/task/myTasks/";
	}

	/**
	 * 获取文档类型的URL
	 * 
	 * @return
	 */
	public String getDocTypesUrl() {
		return serviceSiteRoot + "/resource/doc/docTypes/";
	}

	/**
	 * 获取文档类型对象属性的URL
	 * 
	 * @return
	 */
	public String getDocPropertiesUrl() {
		return serviceSiteRoot + "/resource/doc/docProperties/";
	}

	/**
	 * 获取任务调度文件上传的URL
	 * 
	 * @return
	 */
	public String getTaskUploadFileUrl() {
		return serviceSiteRoot + "/resource/doc";
	}

	/**
	 * 获取服务端规则属性的URL
	 * 
	 * @return
	 */
	public String getPropertyRulesUrl() {
		return serviceSiteRoot + "/resource/property/getPropertyRules/";
	}

	/**
	 * 更新任务调度的URL
	 * 
	 * @return
	 */
	public String getUpdateMyTaskUrl() {
		return serviceSiteRoot + "/resource/task/updateMyTask/";
	}

	/**
	 * 更新属性规则的URL
	 * 
	 * @return
	 */
	public String getUpdatepropertyRulesUrl() {
		return serviceSiteRoot + "/resource/property/updatePropertyRule";
	}

	/**
	 * 添加规则的URL
	 * 
	 * @return
	 */
	public String getAddPropertyRuleUrl() {
		return serviceSiteRoot + "/resource/property/addPropertyRule";
	}

	/**
	 * 远程文件夹浏览的URL
	 * 
	 * @return
	 */
	public String getServiceFoldersUrl() {
		return serviceSiteRoot + "/resource/doc/folders";
	}

	/**
	 * 远程文档的URL
	 * 
	 * @return
	 */
	public String getServiceDocsUrl() {
		return serviceSiteRoot + "/resource/doc/docs";
	}

	/**
	 * 服务器端删除文件的URL
	 * 
	 * @return
	 */
	public String getServiceDeleteFileUrl() {
		return serviceSiteRoot + "/resource/doc/delete";
	}

	/**
	 * 服务器端下载文件的URL
	 * 
	 * @return
	 */
	public String getServiceDownloadSingleFileUrl() {
		return serviceSiteRoot + "/resource/doc/downloadSingleFile";
	}

	/**
	 * 通过规则名获取属性的URL
	 * 
	 * @return
	 */
	public String getPropertyRuleByRuleNameUrl() {
		return serviceSiteRoot
				+ "/resource/property/getPropertyRuleByRuleName/";
	}

	/**
	 * 规则分页的URL
	 * 
	 * @return
	 */
	public String getPropertyRulesForPageViewUrl() {
		return serviceSiteRoot + "/resource/property/getPropertyRulesForView";
	}

	/**
	 * 获取所有任务调度日志的URL
	 * 
	 * @return
	 */
	public String getSchSummaryLogUrl() {
		return serviceSiteRoot + "/resource/log/getSchSummaryLog";
	}

	/**
	 * 获取所有任务调度详细的URL
	 * 
	 * @return
	 */
	public String getSchDetailLogUrl() {
		return serviceSiteRoot + "/resource/log/getSchDetailLog";
	}

	/**
	 * 添加日志的URL
	 * 
	 * @return
	 */
	public String getAddSchSummaryLogUrl() {
		return serviceSiteRoot + "/resource/log/addSummaryLog";
	}

	/**
	 * 更新日志的URL
	 * 
	 * @return
	 */
	public String getUpdateSchSummaryLogUrl() {
		return serviceSiteRoot + "/resource/log/updateSummaryLog";
	}

	/**
	 * 获取调度监控的URL
	 * 
	 * @return
	 */
	public String getTriggerMonitorByTriggerIdUrl() {
		return serviceSiteRoot + "/resource/task/getTriggerMonitorByTriggerId";
	}

	/**
	 * 获取客户端新建监控属性的URL
	 * 
	 * @return
	 */
	public String getAddTriggerMonitorUrl() {
		return serviceSiteRoot + "/resource/task/addTriggerMonitor";
	}

	/**
	 * 获取客户端更新监控属性的URL
	 * 
	 * @return
	 */
	public String getUpdateTriggerMonitorUrl() {
		return serviceSiteRoot + "/resource/task/updateTriggerMonitor";
	}

	/**
	 * 获取客户端新建监控属性的URL
	 * 
	 * @return
	 */
	public String getAddTriggerMonitorRuleUrl() {
		return serviceSiteRoot + "/resource/task/addTriggerRule";
	}

	/**
	 * 获取客户端更新监控规则的URL
	 * 
	 * @return
	 */
	public String getUpdateTriggerMonitorRuleUrl() {
		return serviceSiteRoot + "/resource/task/updateTriggerRule";
	}

	/**
	 * 获取客户端监控属性的URL
	 * 
	 * @return
	 */
	public String getTriggerMonitorRuleUrl() {
		return serviceSiteRoot + "/resource/task/getTriggerRuleByTriggerId";
	}

	/**
	 * 获取服务端用户的URL
	 * 
	 * @return
	 */
	public String getUserInfoUrl() {
		return serviceSiteRoot + "/resource/utils/getUserInfo";
	}

	/**
	 * 获取指定日期是否交易日的URL
	 * 
	 * @return
	 */
	public String getTradeDateUrl() {
		return serviceSiteRoot + "/resource/task/getTradeDate";
		// "http://localhost:8080/WorkplaceFX/resource/task/getTradeDate";//
	}

	/**
	 * 获取调度任务停用服务端请求URL
	 * 
	 * @return
	 */
	public String getDisableTaskUrl() {
		return serviceSiteRoot + "/resource/task/disableTask";
	}

	/**
	 * 获取调度任务启用服务端请求URL
	 * 
	 * @return
	 */
	public String getEnableTaskUrl() {
		return serviceSiteRoot + "/resource/task/enableTask";
	}

	/**
	 * 获取调度任务客户端配置URL
	 * 
	 * @return
	 */
	public String getUpdateTaskClientConfigUrl() {
		return serviceSiteRoot + "/resource/task/updateTaskClientConfig";
	}

	/**
	 * 获取验证调度任务是否启用的URL
	 * 
	 * 
	 * @return
	 */
	public String getCheckTaskExecutabilityUrl() {
		return serviceSiteRoot + "/resource/task/checkTaskExecutability";
	}

	/**
	 * 获取服务端的登陆URL
	 * 
	 * @return
	 */
	public String getHeartBeatUrl() {
		return serviceSiteRoot + "/resource/auth/heartBeat";
	}

	/**
	 * 获取服务端异常的调度任务
	 * 
	 * @return
	 */
	public String getTriggerErrorExitByIPAndUserCodeUrl() {
		return serviceSiteRoot
				+ "/resource/task/getTriggerErrorExitByIPAndUserCode";
	}

	/**
	 * 通过属性UUD获取属性KeyCode表的信息
	 * 
	 * @return
	 */
	public String getKeyCodeListByProUuidUrl() {
		return serviceSiteRoot + "/resource/utils/getKeyCodeListByProUuid";
	}

	/**
	 * 通过属性UUD获取属性KeyCode表的信息
	 * 
	 * @return
	 */
	public String getMyServiceClientUrl() {
		return serviceSiteRoot + "/resource/utils/getMyServiceClient";
	}

	/**
	 * 删除异常退出表中记录
	 * 
	 * @return
	 */
	public String getDeleteTriggerErrorExitUrl() {
		return serviceSiteRoot + "/resource/task/deleteTriggerErrorExit";
	}

	/**
	 * 删除异常退出表中记录
	 * 
	 * @return
	 */
	public String getReplaceFileUrl() {
		return serviceSiteRoot + "/resource/doc/replaceFile";
	}

	/**
	 * 检查文件是否存在
	 * 
	 * @return
	 */
	public String getCheckFileUrl() {
		return serviceSiteRoot + "/resource/doc/checkFile";
	}

}
